<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class BannerRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'title' =>'required|between:2,25',
            'url' => 'required|url',
            'sort'=> 'required|numeric',
            'image'=> 'mimes:jpeg,bmp,png,gif'

        ];
    }

    public function messages()
    {
        return [
            'title.required'=>'标题不能为空',
            'title.between' => '标题必须介于 3 - 25 个字符之间。',
            'url.required' =>'链接不能为空',
            'url.url' =>'无效的链接',
            'sort.required'=>'排序不能为空',
            'sort.numeric'=>'排序字段必须是数字',
            'image.mimes' =>'轮播图片必须是 jpeg, bmp, png, gif 格式的图片',
        ];
    }
}
